package io.github.ecsoya.fabric;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

public class FabricRequest implements Serializable{

	/**
	 * Chaincode function name.
	 */
	public String function;

	/**
	 * Chaincode function arguments.
	 */
	public String[] arguments;

	public FabricRequest(String function, String... arguments) {
		this.function = function;
		this.arguments = arguments;
	}

	public String getFunction(){
		return this.function;
	}

	public void setFunction(String function){
		this.function = function;
	}

	public String[] getArguments(){
		return this.arguments;
	}
	
	public void setArguments(String[] arguments){
		this.arguments = arguments;
	}

	public void checkValidate() throws FabricException {
		if (function == null || function.equals("")) {
			throw new FabricException("The executable function name is empty.");
		}
	}

	@Override
	public String toString(){
		return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
	}
}
